package com.fulihui.wgj.admin.integration.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.fulihui.common.conv.BeanConv;
import com.fulihui.common.result.rpc.SimpleResult;
import com.fulihui.wgj.admin.api.retention.request.RetentionQueryReq;
import com.fulihui.wgj.admin.api.retention.vo.RetentionVO;
import com.fulihui.wgj.admin.integration.RetentionClient;
import com.fulihui.wgj.facade.dto.WxSevenRetentionDTO;
import com.fulihui.wgj.facade.request.retention.WxSevenRetentionQueryRequest;
import com.fulihui.wgj.facade.service.retention.WxSevenRetentionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: JY
 * @date: 2018/7/4 11:12
 */
@Service("retentionServiceClient")
public class RetentionClientImpl implements RetentionClient {

    @Reference(version = "1.0.0")
    WxSevenRetentionService wxSevenRetentionService;

    /**
     * 查询公众号七日留存数据
     *
     * @param queryReq
     */
    @Override
    public List<RetentionVO> queryWxSevenRetentions(RetentionQueryReq queryReq) {

        WxSevenRetentionQueryRequest request = BeanConv.copy(queryReq, WxSevenRetentionQueryRequest.class);

        //rpc调用
        SimpleResult<List<WxSevenRetentionDTO>> listSimpleResult = wxSevenRetentionService.queryWxSevenRetentions(request);

        //返回对象
        List<RetentionVO> renList = null;

        if (listSimpleResult.getData() != null) {
            renList = BeanConv.copy(listSimpleResult.getData(), RetentionVO.class);
        }

        return renList;
    }

}
